<template>
	<view class="page">
		<view class="items" v-for="(items,index) in shiList" :key="items.id" @click="chooseCity(items)">
			{{items.name}}
		</view>
		<!-- 		<view class="cose" @click="end">
			X
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				shiqu: [],
				shiList: [],
				userType: null,
			}
		},


		onLoad(options) {
			this.shiqu = JSON.parse(options.data)
			this.getCityTree(this.shiqu[0].id)
		},
		created() {
			this.getUser()
		},
		methods: {
			getUser() {
				this.$axios.request(this.$api.getUser, "GET").then((val) => {
					this.userType = val.data.userType
				})
			},
			// 获取城市
			getCityTree(ID) {
				this.$axios.request(this.$api.getCityApi, "GET", {
					hasTowner: 1,
					pid: ID
				}).then((val) => {
					this.shiList = val.data
				})
			},
			chooseCity(city) {
				this.shiqu[1] = {
					...city
				}
				let pages = getCurrentPages()
				let prevPage = pages[pages.length - 3]
				let di_qu = []
				this.shiqu.forEach(t => {
					di_qu.push(t.name)
				})
				prevPage.$vm.form.cityId = this.shiqu[0].id
				prevPage.$vm.form.districtId = this.shiqu[1].id
				prevPage.$vm.cityStr = di_qu.join(',')
				uni.navigateBack({
					delta: 2 // 返回页面数
				})
			},
		}
	}
</script>

<style>
	.page {
		width: 100%;
		height: 100vh;
		background-color: #fff;
		overflow-y: auto;
		padding-bottom: 60rpx;
	}

	.items {
		width: 100%;
		padding: 0 24rpx;
		height: 60rpx;
		/* background-color: red; */
		border-bottom: 2rpx solid #eee;
		line-height: 60rpx;
	}

	.cose {
		position: fixed;
		right: 30rpx;
		bottom: 60rpx;
		width: 85rpx;
		height: 85rpx;
		background-color: #3975EA;
		border-radius: 42.50rpx;
		text-align: center;
		line-height: 85rpx;
		color: #FFFFFF;
		z-index: 999;

	}
</style>